import 'package:flutter/material.dart';
import 'package:flutter_base/19_name_route_pop/registerThree.dart';

class RegisterTwo extends StatefulWidget {
  const RegisterTwo({super.key});

  @override
  State<RegisterTwo> createState() => _RegisterTwoState();
}

class _RegisterTwoState extends State<RegisterTwo> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('这是注册界面22222'),
      ),
      body: ElevatedButton(
          onPressed: () {
            // Navigator.of(context).pushNamed('/three');

            /// 跳转然后替换掉当前路由，比如当下是1，那么3会直接替换掉2
            // Navigator.of(context)
            //     .pushReplacement(MaterialPageRoute(builder: (context) {
            //   return const RegisterThree();
            // }));

            /// newroute表示要跳转的路由
            /// predict表示返回后要跳到的路由
            /// 这里表示的是从第三个页面直接返回home
            Navigator.of(context).pushAndRemoveUntil(
                MaterialPageRoute(builder: (ctx) => const RegisterThree()),
                ModalRoute.withName('/'));
          },
          child: const Text('注册2')),
    );
  }
}
